package model.item;

import model.entity.BasicEntity;
import model.entity.stats.StatSet;
import model.skill.Projectile;
import model.skill.ProjectileInformation;
import utilities.*;

public class EquippableItem extends TakeableItem implements Archiveable {

	private String equipmentType;
	private EquipmentSlot equipmentSlot; 
	private StatSet stats;
	
	public EquippableItem() {
		this(null);
	}
	
	public EquippableItem(String name)
	{
		super(name);
		equipmentType = null;
		equipmentSlot = EquipmentSlot.HEAD;
		stats = null; 
	}
	
	public EquippableItem(String name, Projectile projectile, String equipmentType, EquipmentSlot equipmentSlot, StatSet stats, int price)
	{
		super(name, projectile ,price);
		this.equipmentType = equipmentType;
		this.equipmentSlot = equipmentSlot;
		this.stats = stats;
	}
	
	
	public String getEquipmentType()
	{
		return equipmentType;
	}

	public EquipmentSlot getEquipmentSlot()
	{
		return equipmentSlot;
	}

	public StatSet getStats()
	{
		return stats;
	}

	public void use(BasicEntity entity)
	{
		if(entity.getInventory().contains(this))
		{
			entity.EquipItem(this);
			entity.removeItem(this);
		}
		else
		{
			entity.UnequipItem(this);
		}
		
	}
	
	public Archive save() {
		Archive archive = super.save();
		
		archive.putAttribute("equipmentType", this.equipmentType);
		
		return archive;
	}
	
	public void load(Archive archive) {
		super.load(archive);
		
		this.equipmentType = archive.getAttribute("equipmentType");
	}
	
}
